# 记录一下 React input输入框不生效的问题 选一个能用就行 let input = document.getElementById(‘userName’) let lastValue = input.value input.value=‘123’ let event = new Event(‘input’, { bubbles: true }) let tracker = input.\_valueTracker if(tracker) { tracker.setValue(lastValue) } input.dispatchEvent(event) let input = document.querySelector(’input‘);  let lastValue = input.value;  input.value = ’test‘;  let event = new Event('input', { bubbles: true });  event.simulated = true;   et tracker = input.\_valueTracker;  if (tracker) {     tracker.setValue(lastValue);  }  input.dispatchEvent(event); 来源:[vue和react使用js模拟键盘输入\_js模拟键盘输入vue input-CSDN博客](https://blog.csdn.net/weixin_46774564/article/details/123254550) [vue和react使用js模拟键盘输入\_js模拟键盘输入vue input-CSDN博客](https://blog.csdn.net/weixin_46774564/article/details/123254550)